<%@page contentType="text/html; charset=UTF-8"%>
<%@page import="ChartDirector.*" %>
<%
// 折线图数据
double[] data1 = {28, 35, 40, 75, 68, 54, 60, 50, 62, 75, 65, 75};
double[] data2 = {32, 30, 44, 66, 74, 59, 67, 65, 48, 58, 65, 79};

// 折线图标签-横坐标
String[] labels = {"1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11",
    "12"};

// 创建一个XYChart对象大小为250x260像素 
XYChart c = new XYChart(250, 260);
//设置图形默认字体，同时可以解决中文乱码的问题s
c.setDefaultFonts("simsun.ttc", "simhei.ttc");
//设置背景颜色
//c.setBackground(0xefeff0);
int clor[]={0x000000,0xFFE743,0x000060,0xFFFFE0,0x0000B0,0xFFF0B0,0x00100,0xFFE743};
//c.setBackground(c.linearGradientColor2(0,0,250,250,clor,true));
c.setBackground(c.gradientColor(clor));
//设置绘图区域为离左边沿为30，底部20处，大小为200x200
c.setPlotArea(30, 30, 200, 200);
//添加图例,距左40，上为0，横向显示，字体为默认字体，大小为9号,，背景透明
c.addLegend(40, 10, false, "", 9).setBackground(Chart.Transparent);
//添加折线数据
Layer layer = c.addLineLayer2();
//设置线宽
layer.setLineWidth(3);
//添加数据，设置线的颜色，同示说明数据代表的项
layer.addDataSet(data1,0xff0000,"本期");
layer.addDataSet(data2,0x008800,"上期");


// 设置标签在X轴上
c.xAxis().setLabels(labels);

//以3为分隔显示标签
//c.xAxis().setLabelStep(3);

//输出图形
String chart1URL = c.makeSession(request, "chart1");

// 在图片上显示标签
String imageMap1 = c.getHTMLImageMap("", "",
    "title='时间 {xLabel}: 传输 {value} GBytes'");
%>
<html>
	<head>
		<title>坐标图——折线图示例</title>
	</head>
	<body>
	<hr color="#000080">
<div style="font-size:9pt; font-family:verdana; margin-bottom:1.5em">
    <a href="viewsource.jsp?file=<%=request.getServletPath()%>">View Source Code</a>
</div>
<img src='<%=response.encodeURL("getchart.jsp?"+chart1URL)%>'
    usemap="#map1" border="0">
<map name="map1"><%=imageMap1%></map>
	</body>
</html>





